/**
 * form查询增加前台可以直接查询的关键字
 * @author xuqw
 * @param {Object} form
 * // 前后台结合的，查询条件操作符，传回后台生成Arg
        opertion : {
            IsNull : "IsNull", // XXXX is null
            IsNotNull : "IsNotNull", // XXXX is not null
            EqualTo : "EqualTo", // 等于 =
            NotEqualTo : "NotEqualTo", // 不等于 <>
            GreaterThan : "GreaterThan", // 大于 >
            GreaterThanOrEqualTo : "GreaterThanOrEqualTo", // 大于等于 >=
            LessThan : "LessThan", // 小于 <
            LessThanOrEqualTo : "LessThanOrEqualTo", // 小于等于 <=
            Like : "Like", // 模糊查询 XXXX like %value%
            NotLike : "NotLike", // XXXX not like %value%
            LeftLike : "LeftLike", // XXXX like %value
            NotLeftLike : "NotLeftLike", // XXXX not like %value
            RightLike : "RightLike", // XXXX like value%
            NotRightLike : "NotRightLike", // XXXX not like value%
            In : "In", // in ()
            NotIn : "NotIn", // not in ()
            Between : "Between", // 范围 between
            NotBetween : "NotBetween"// not between
        }
 * 
 */
/**
 * form提交的时候组装查询条件的参数
 * @author xuqw
 * @param {Object} form
 */
function pkgParam(form){
	$form = $(form);
	var queryConditions = formAddQueryConditions($form.serializeArray());
	
	//组装查询条件
	var qryInput = document.createElement("input");   
	qryInput.type="hidden";   
	qryInput.name="queryConditions";  
	qryInput.value=queryConditions;
    form.appendChild(qryInput);  
	return true;
}


/**
 * 添加查询使用的condition对象
 * 取出form里面的所有参数，并组装queryConditions，字段结构如下{\"paramName\":\""+name+"\",\"operation\":\""+opertion+"\",\"paramValue\":[\""+value+"\"]},";
 * @author xuqw
 */
function formAddQueryConditions(array){
	var conditions = ""
		var orderField = "id";
		var orderDirection = "asc";
		for(var i = 0;i<array.length;i++){
			var name = array[i].name;
			var value = array[i].value;
			var opertion = $("input[name='"+name+"']").attr("opertion");
			//值为空
			if(value==undefined||value==""){
				continue;
			}
			if(name=="orderField"){
				orderField = value;
				continue;
			}
			if(name=="orderDirection"){
				orderDirection = value;
				continue;
			}
			if(name=="pageSize"||name=="pageCurrent"||name=="page"||name=="limit"){
				continue;
			}
			if(opertion==undefined||opertion=="undefined"){
				opertion="EqualTo";
			}
			conditions += "{\"paramName\":\""+name+"\",\"operation\":\""+opertion+"\",\"paramValue\":[\""+value+"\"]},";
		}
		if(""!=conditions){
			conditions = "["+conditions.substring(0, conditions.length-1)+"]";
	    }
		
//		var queryConditions = new Object();
//		queryConditions.name="queryConditions";
//		queryConditions.value=conditions;
		//把queryConditions对象加到form传回的数组里面进去
//		array.unshift(queryConditions);
		return conditions;
}